<?php

namespace App\Console\Commands\Push;

use App\Service\Push\PushBaseFuncService;
use App\Service\Push\PushComposeService;
use App\Service\Push\PushConfigService;
use App\Service\Push\PushMockFuncService;
use Illuminate\Console\Command;

class TaskPush extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'push:task {bizType}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '任务聚合推送(总部|分公司|个人)';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        ini_set('memory_limit', '1024M');

        $bizType = $this->argument('bizType');

        // 基础任务的获取sql
        $func = (new PushBaseFuncService());

        switch ($bizType) {

            // 用户
            case PushConfigService::BIZ_TYPE_USER:
                $data = (new PushComposeService($func))->composeUser();
                break;

            // 总部
            case PushConfigService::BIZ_TYPE_KF:
                $data = (new PushComposeService($func))->composeKf();
                break;

            // 省区
            case PushConfigService::BIZ_TYPE_PROVINCE:
                $data = (new PushComposeService($func))->composeProvince();
                break;
            default:
                $data = "错误的业务类型";
        }
        dump($data);
    }

    public function readme()
    {
        // 1. 基础任务的获取sql
        $func = new PushBaseFuncService();

        // 2. 调试/debug推送功能的mock数据
        $func = new PushMockFuncService();

        // 用户的任务推送
        (new PushComposeService($func))->composeUser();
    }
}
